package ciyuan.Recipes;

import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraftforge.event.entity.player.PlayerEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;

@Mod.EventBusSubscriber
public class CarvingKnife  {

    @SubscribeEvent
    public static void onCraft(PlayerEvent.ItemCraftedEvent event) {
        if (event.getCrafting().sameItem(new ItemStack(Items.STICK))) {
            for (int i=0;i<event.getInventory().getContainerSize();i++) {
                if (event.getInventory().getItem(i)!=null) {
                    ItemStack itemStack = event.getInventory().getItem(i);
                    if (itemStack.getItem() instanceof ciyuan.Item.Tools.CarvingKnife) {
                        if (itemStack.getMaxDamage()>itemStack.getDamageValue()) {
                            itemStack.setDamageValue(itemStack.getDamageValue()+1);
                            event.getPlayer().addItem(itemStack);
                        }
                    }
                }
            }
        }
    }

}
